<{extend name="base" /}>
    <{block name="body" }>
        <div class="layui-body ">
            <div class="layui-tab layui-tab-brief">
                <ul class="layui-tab-title">
                    <li class="">
                            <a href="<{:url('admin/sm/index')}>">已添加列表</a>
                        </li>
                        <li class="layui-this">
                            <a href="<{:url('admin/sm/create',['style_id'=>1])}>">样式一</a>
                        </li>
                        <li >
                            <a href="<{:url('admin/sm/create',['style_id'=>2])}>">样式二</a>
                        </li>
                        <li >
                            <a href="<{:url('admin/sm/create',['style_id'=>3])}>">样式三</a>
                        </li>
                        <li>
                            <a href="<{:url('admin/sm/create',['style_id'=>4])}>">样式四</a>
                        </li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show" id="app">
                        <div class="left">
                            <form class="layui-form" method="post" action="<{:url('admin/sm/save')}>">
                                <input type="hidden" name="style" value="1">
                                <{php}>
                                if(request()->action() == 'edit'){
                                    echo '<input type="hidden" name="type" value="edit">';
                                    echo '<input type="hidden" name="id" value="'.request()->get('id').'">';
                                }
                                <{/php}>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">标题</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="content[title]" lay-verify="required" v-model='title' placeholder="{用此符号可飘红，支持多个} 必须成对书写"
                                            class="layui-input">
                                    </div>
                                </div>

                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">描述</label>
                                    <div class="layui-input-block">
                                        <textarea name="content[desc]" lay-verify="required"  placeholder="{用此符号可飘红，支持多个} 必须成对书写"
                                            class="layui-textarea" v-model='desc'></textarea>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">链接</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="content[url]" v-model='url'  lay-verify="required|url" placeholder="例如：http://baidu.com" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">域名</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="content[host]" v-model='host' lay-verify="required" placeholder="例如：m.baidu.com" class="layui-input">
                                    </div>
                                </div>
                                

                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="right" id="sm-search">
                            <link rel="stylesheet" href="/sm/css/style.css" />
                            <div class="result card">
                                <a class="title" :href="url">
                                    <i v-html="Ctitle"></i>
                                    <img src="" alt="手机版">
                                    <p class="abs" v-html="Cdesc"></p>
                                </a>
                                <div class="host">
                                    <span v-html="Chost"></span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
<{/block}>
<{block name="script" }>
                <style type="text/css">
                    .left,
                    .right {
                        float: left;
                    }

                    .left {
                        width: 60%;
                    }

                    .right {
                        height: 550px;
                        margin-left: 60px;
                        width: 300px;
                        border: 2px solid #ccc;
                        border-radius: 20px;
                        padding: 20px 13px;
                        background: #f1f1f1;
                        box-shadow: 1px 2px #eeeeee5c;
                    }
                </style>
                <script src="/static/js/vue.js"></script>
                <script type="text/javascript">
                    var vue = new Vue({
                        el: "#app",
                        data: {
                            title: '',
                            desc: '',
                            host: '',
                            url:''
                        },
                        computed: {
                            Ctitle: function () {
                                if (this.title == '') {
                                    return '妇科医院哪家好_医院妇科【官方网站做...';
                                }
                                return this.title.replace(/{/g, '<em>').replace(/}/g, '</em>');
                            },
                            Cdesc: function () {
                                if (this.desc == '') {
                                    return '妇科医院，是专业妇科医院，长期致力于妇科疾病的研究和...主要诊疗妇科项目有：无痛<em>人流</em>,...';
                                }
                                return this.desc.replace(/{/g, '<em>').replace(/}/g, '</em>');
                            },
                            Chost: function () {
                                if (this.host == '') {
                                    return 'm.sm.cn';
                                }
                                return this.host;
                            },
                        }
                    });

                    <{php}>
                        if(request()->action() == 'edit'){

                            echo "vue.title = '".$data['content']['title']."';";
                            echo "vue.desc = '".$data['content']['desc']."';";
                            echo "vue.host = '".$data['content']['host']."';";
                            echo "vue.url = '".$data['content']['url']."';";

                        }
                    <{/php}>

                </script>
                <{/block}>